lib/repo-commit: Fix types of content size cache entries
authorPhilip Withnall <withnall@endlessm.com>
Mon, 10 Jul 2017 18:48:52 +0000 (19:48 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 11 Jul 2017 14:55:55 +0000 (14:55 +0000)
Use goffset rather than gsize for file sizes. More importantly, get the
unpacked_size from g_file_info_get_size() (goffset) rather than from the
splice return value, which has type gssize.

This will make a difference on 32-bit systems, where goffset is defined
as off64_t, but gsize is 32 bits.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #999
Approved by: cgwalters

src/libostree/ostree-repo-commit.c

index baeef3f9b09e3dd8460e8191926893335090ae04..55d5b16a0eacafaa9df80dc2892dd83ff578e45a 100644 (file)
@@ -299,13 +299,13 @@ commit_loose_regfile_object (OstreeRepo        *self,
 
 typedef struct
 {
-  gsize unpacked;
-  gsize archived;
+  goffset unpacked;
+  goffset archived;
 } OstreeContentSizeCacheEntry;
 
 static OstreeContentSizeCacheEntry *
-content_size_cache_entry_new (gsize unpacked,
-                              gsize archived)
+content_size_cache_entry_new (goffset unpacked,
+                              goffset archived)
 {
   OstreeContentSizeCacheEntry *entry = g_slice_new0 (OstreeContentSizeCacheEntry);
 
@@ -325,8 +325,8 @@ content_size_cache_entry_free (gpointer entry)
 static void
 repo_store_size_entry (OstreeRepo       *self,
                        const gchar      *checksum,
-                       gsize             unpacked,
-                       gsize             archived)
+                       goffset           unpacked,
+                       goffset           archived)
 {
   if (G_UNLIKELY (self->object_sizes == NULL))
     self->object_sizes = g_hash_table_new_full (g_str_hash, g_str_equal,
@@ -594,7 +594,7 @@ write_content_object (OstreeRepo         *self,
    */
   g_auto(OtCleanupUnlinkat) tmp_unlinker = { self->tmp_dir_fd, NULL };
   g_auto(GLnxTmpfile) tmpf = { 0, };
-  gssize unpacked_size = 0;
+  goffset unpacked_size = 0;
   gboolean indexable = FALSE;
   /* Is it a symlink physically? */
   if (phys_object_is_symlink)
@@ -643,10 +643,11 @@ write_content_object (OstreeRepo         *self,
           /* Don't close the base; we'll do that later */
           g_filter_output_stream_set_close_base_stream ((GFilterOutputStream*)compressed_out_stream, FALSE);
 
-          unpacked_size = g_output_stream_splice (compressed_out_stream, file_input,
-                                                  0, cancellable, error);
-          if (unpacked_size < 0)
+          if (g_output_stream_splice (compressed_out_stream, file_input,
+                                      0, cancellable, error) < 0)
             return FALSE;
+
+          unpacked_size = g_file_info_get_size (file_info);
         }
 
       if (!g_output_stream_flush (temp_out, cancellable, error))